import path from "path"
import dev from "./dev"
import prod from "./prod"
declare global {
  const API_ENV: string
  const TARO_ENV: string
}
const config = {
  projectName: "大华股份",
  date: "2021-2-1",
  designWidth: 750,
  deviceRatio: {
    640: 2.34 / 2,
    750: 1,
    828: 1.81 / 2
  },
  sourceRoot: "src",
  outputRoot: `dist/${process.env.TARO_ENV}`,
  plugins: [],
  defineConstants: {
    API_ENV: JSON.stringify(process.env.API_ENV || "test"),
    TARO_ENV: JSON.stringify(process.env.TARO_ENV || "h5")
  },
  copy: {
    patterns: [],
    options: {}
  },
  framework: "react",
  mini: {
    postcss: {
      pxtransform: {
        enable: true,
        config: {}
      },
      url: {
        enable: true,
        config: {
          limit: 1024 // 设定转换尺寸上限
        }
      },
      cssModules: {
        enable: false, // 默认为 false，如需使用 css modules 功能，则设为 true
        config: {
          namingPattern: "module", // 转换模式，取值为 global/module
          generateScopedName: "[name]__[local]___[hash:base64:5]"
        }
      }
    }
  },
  h5: {
    router: {
      mode: "browser", // 或者是 'hash'
      basename: '/h5'
    },
    publicPath: "/h5",
    staticDirectory: "static",
    postcss: {
      autoprefixer: {
        enable: true,
        config: {}
      },
      cssModules: {
        enable: false, // 默认为 false，如需使用 css modules 功能，则设为 true
        config: {
          namingPattern: "module", // 转换模式，取值为 global/module
          generateScopedName: "[name]__[local]___[hash:base64:5]"
        }
      }
    },
    esnextModules: ["taro-ui"]
  },
  alias: {
    "@@": path.resolve(__dirname, "../", "src")
  },
  sass: {
    resource: ["src/assets/theme/custom-theme.scss"],
    projectDirectory: path.resolve(__dirname, "..")
  }
}
console.log("79", process.env.NODE_ENV, prod, process.env.API_ENV)
export default (merge: Function) => {
  return merge({}, config, process.env.NODE_ENV === "development" ? dev : prod)
}
